﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Kcadastro
{
    public partial class inicio : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            masterPageKcad m = Master as masterPageKcad;
            //TODO SJC Verificar se autenticado

            divDesLogado.Visible = !Request.IsAuthenticated;
            divLogado.Visible = Request.IsAuthenticated;

            //m.idFerr = 1;
        }
        //TODO:BEGIN SJC Entrar LOGIN
        protected void bt_entrar_Click(object sender, EventArgs e)
        {
            classes.usuarios users = new classes.usuarios();
            if (users.logar(tblogin_email.Text, tblogin_senha.Text))
            {
                lt_msg.Text = "";
                //TODO SJC Autenticação  WebForms
                if (Session["Puser"] != null)
                {
                    System.Web.Security.FormsAuthentication.SetAuthCookie(((classes.usuarios.permissao)Session["Puser"]).PRIMEIRONOME, false);
                }
                Response.Redirect("~/inicio.aspx");
            }
            else
            {
                lt_msg.Text = "<font color=\"RED\">" + users.MSG + "</font>";
            }
        }
    }
}